package com.pinda.service.impl;


import com.pinda.base.entity.PdCoreOrg;
import com.pinda.mapper.PdCoreOrgMapper;
import com.pinda.service.IPdCoreOrgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pinda.vo.HomeVo;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 组织 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-06-24
 */
@Service
public class PdCoreOrgServiceImpl extends ServiceImpl<PdCoreOrgMapper, PdCoreOrg> implements IPdCoreOrgService {

    @Resource
    private  PdCoreOrgMapper pdCoreOrgMapper;

    @Override
    public PdCoreOrg findPdCoreOrgById(String id) {
        return pdCoreOrgMapper.findPdCoreOrgById(id);
    }

    @Override
    public HomeVo queryHomeService(Integer loginid) {
        HomeVo homeVo=new HomeVo();
        //查询登录用户所在的网点
        HomeVo homeVo1 = this.pdCoreOrgMapper.queryLoginorg(loginid);
        homeVo.setPcoid(homeVo1.getPcoid());
        homeVo.setAddress(homeVo1.getAddress());
        homeVo.setPconame(homeVo1.getPconame());
        homeVo.setPa1name(homeVo1.getPa1name());
        homeVo.setPa2name(homeVo1.getPa2name());
        homeVo.setPa3name(homeVo1.getPa3name());
        //查询当前机构的下属机构个数和系统员工个数
        HomeVo queryorgoruser = this.pdCoreOrgMapper.queryorgoruser(homeVo.getPcoid());
        homeVo.setOrgCount(queryorgoruser.getOrgCount());
        homeVo.setStaffCount(queryorgoruser.getStaffCount());
        //待分配作业范围
        homeVo.setScopejobCount(queryorgoruser.getScopejobCount());
        //取件待办
        homeVo.setPickuptodoCount(queryorgoruser.getPickuptodoCount());
        //派件待办
        homeVo.setSendthingsCount(queryorgoruser.getSendthingsCount());
        //
        homeVo.setCollectCount(queryorgoruser.getCollectCount());
        homeVo.setCollectbacklogCount(queryorgoruser.getCollectbacklogCount());
        homeVo.setCollectHavebeenCount(queryorgoruser.getCollectHavebeenCount());
        homeVo.setCollectdoneCount(queryorgoruser.getCollectdoneCount());
        homeVo.setPaijrenwuCount(queryorgoruser.getPaijrenwuCount());
        homeVo.setPaijbacklogCount(queryorgoruser.getPaijbacklogCount());
        homeVo.setPaijunfinishedCount(queryorgoruser.getPaijunfinishedCount());
        homeVo.setPaijidoneCount(queryorgoruser.getPaijidoneCount());
        return homeVo;
    }

    @Override
    public String selectName(long id) {
        PdCoreOrg pdCoreOrg = pdCoreOrgMapper.selectById(id);
        return pdCoreOrg.getName();
    }
}
